﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CMS.Data.Repositorios;
using CMS.Data.Classes;

namespace App.UI
{
    public partial class Site : System.Web.UI.MasterPage
    {
       
        //Objs
        UsuarioRepository usuarioRepository = new UsuarioRepository();


        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                VerifyUser();
            }
        }

        /// <summary>
        /// Validador de Usuário
        /// </summary>
        private void VerifyUser()
        {
            //Retorna Sessão de Login
            
            if (HttpContext.Current.Session["User"] != null && HttpContext.Current.Session["Password"] != null)
            {
                String User = Session["User"].ToString();
                String Password = Session["Password"].ToString();

                Usuario usuario = usuarioRepository.SelectByEmail(User);

                ltlUsuario.Text = usuario.Nome;
               
            }
            else
                Response.Redirect("Login.aspx");
        }

        protected void btnLogout_Click(object sender, EventArgs e)
        {
            Session.Abandon();
            Response.Redirect("Login.aspx");
        }
    }
}